<!--
 * @Author: liuyonghu
 * @Date: 2020-03-04 21:51:34
 * @LastEditTime: 2023-03-21 15:44:57
 * @LastEditors: liuyonghu
 * @FilePath: \demo\1.html
-->
<!DOCTYPE html>
<html xmlns:wb="http://open.weibo.com/wb">

<head>
  <meta charset="utf-8" />
  <title></title>
  <script src="https://tjs.sjs.sinajs.cn/open/api/js/wb.js" type="text/javascript" charset="utf-8"></script>
</head>

<body style="background-color: #f8f8f8">
  <button onclick="clikBtn()">clikBtn</button>
  <script type="text/javascript">
    // let a = {"a":1,"b":2};
    // b = a;
    // b.a  = 3;
    // console.log(a);

    function clikBtn(params) {
      window.open('https://lenovo.com')
    }
    window.onload = () => {
      console.log(" === window.onload 1==== ")
    }
    window.onload = () => {
      console.log(" === window.onload 2==== ")
    }
    window.onload = () => {
      console.log(" === window.onload 3==== ")
    }
    window.onload = () => {
      console.log(" === window.onload 4==== ")
    }

    window.addEventListener('load', () => {
      console.log(" === window.onload 5==== ")
    })
    window.addEventListener('load', () => {
      console.log(" === window.onload 6==== ")
    })
    // 
    let ar = ["1", "2", "3"];
    let [...arr] = ar;
    console.log(arr);

    let obj = { key: 1231 };
    let obj1 = obj;
    let getObj2 = () => {
      return {
        ...obj
      };
    };
    let obj2 = getObj2();
    obj2.key = 11
    console.log(" obj - ", JSON.stringify(obj));
    console.log(" obj1 - ", JSON.stringify(obj1));
    console.log(" obj2 - ", JSON.stringify(obj2));


    const o = {
      removeItems(keys) {
        const that = this;
        keys.forEach((key) => {
          console.log(that === this);
        });
      },
    }

    o.removeItems(["a", "d", "c"])

    const promise_func = () => new Promise((resolve, reject) => {
      // reject("这是一个错误");
      // throw "throw error"
      // resolve();
    });
    const asyncFunc = async () => {
      try {
        const res = await promise_func().catch((error) => {
          console.log("promise_func catch == ", error);
        });
      } catch (error) {
        console.log("error == ", error);
      }

    };
    asyncFunc();
    // let img = new Image();
    // img.src = 'https://tse1-mm.cn.bing.net/th/id/OIP.bbPzMM-vrx06vCzm_RgnKQHaEe?w=300&h=181&c=7&o=5&dpr=2&pid=1.7';
    // img['status'] = false;
    // img.onload = function(e) {
    // 	img.status = true;
    // 	console.log(img.status)
    // };


    channel = new BroadcastChannel("dadadasdad");

    channel.addEventListener("message", (e) => {
      console.log("123 - ",e)
    })

    channel.onmessage = (e) => {
      console.log("123", e)
    }

  </script>
</body>

</html>